﻿using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;

namespace homework1_auto_ques.pages
{
    public class CategoryInfo
    {
        public string Name { get; set; }
        public int Value { get; set; }
    }
    /// <summary>
    /// Page1.xaml 的交互逻辑
    /// </summary>
    public partial class Page1 : Page
    {
        public Page1()
        {
            InitializeComponent();
            setList();
        }

        //赋值选项卡
        private void setList()
        {
            //赋值选项卡1
            List<CategoryInfo> list1 = new List<CategoryInfo>();
            list1.Add(new CategoryInfo { Name = "算数", Value = 0 });
            list1.Add(new CategoryInfo { Name = "背单词", Value = 1 });
            selectMode1.ItemsSource = list1;
            selectMode1.DisplayMemberPath = "Name";
            selectMode1.SelectedValuePath = "Value";
            //赋值选项卡2
            int[] numList = { 5, 10, 25, 50, 100};
            selectMode2.ItemsSource = numList;
            //赋值选项卡3
            int[] timeList = new int[11];
            for (int i = 0; i < timeList.Length; i++)
            {
                timeList[i] = 10 + i;
            }
            selectMode3.ItemsSource = timeList;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // 获取ComboBox的选定项
            CategoryInfo selectedMode = selectMode1.SelectedItem as CategoryInfo;
            int selectedQuesNum = selectMode2.SelectedItem != null ? (int)selectMode2.SelectedItem : 0;
            int selectedQuesTime = selectMode3.SelectedItem != null ? (int)selectMode3.SelectedItem : 0;

            // 检查是否都不为空
            if (selectedMode != null && selectedQuesNum != 0 && selectedQuesTime != 0)
            {
                Frame frame2 = new Frame() { Content = new pages.Page2(selectedQuesTime, selectedQuesNum, selectedMode.Value) };
                // 导航到Page2
                MainWindow.win.ContentCon.Content = frame2;
            }
            else
            {
                // 显示提示消息
                MessageBox.Show("请先选择模式");
            }
        }

        private void Image_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            MainWindow.win.Close();
        }
    }
}
